moved print function out of main