Refactoring for better logical order