corrected for loop in print_stack function and removed debug snippet