Moved print switch statement into function