Added error check for zero divide