Remove inneficiencies in the code