Optimise the code