added print statements to see flow of control