Optimazed the print code