Refactor end