am refactor