Fix of logic error that could allow divide by 0