Refactor: cleaner and more modular code