Made check_stack deterministic