Changing variable names and optimizing