added check to avoid possibility of division by zero