added try/catch for possible ZeroDivisionError