fix division by zero bug