First attempt to refactoring