fix possible divide zero error