Added printf statements for understandability of program flow.