Added the tryPrinting method into the code