minor refactor and rename vars