A bit of refactoring to increase code quality