Added checks for divisiou and modulo by zero