Trying to add in efficiencies to the code