fix divide by zero bug