moved print function out