Trying to be smarter about the variables. This is pretty old code