Fixed bug with division by zero