Off by 1 error - small optimisation