a couple of optimisations made