Modified printInOrder method