Refactoring code for more readability