alan refactor