Refactoring a little bit