FredrichO - fixed possible divide by zero error