added a little optimisation