Improved the print function