Refactoring for less complex code