Improved print function