code refactor end