Removing unnecessary values in variables