fixed potential division by zero error