Changes on Code to make more efficient