phx refactoring