Refactor to reduce number of variables.