fix zero division bugs