Code refactorized