Refactoring for better structure