return output string in functions instead of echo/printf