Refactoring for shorter code