divde by zero check and write corrected