Code refactoring for better practice 2