refactor pass 1