Refactor handlers to be more modular