refactor to make more readable