Refactored outputhandler