Refactor unifying the output functions.