fixed possible segfault with divison by 0