Fix division by 0 problem