fixed bug: divide by zero @Liang Barsky