Refactorized code