refactor to make more legible