simplified changing variable function