Refactor for optimisation and elegance