Removing unwanted variables and clean up the code