reverted code for post order