attempt 3 some optimisation