refactor xy