Protection against division by 0 added.