Refactoring a lil bit