Refactor existing code