Moved output to a single function