The check_order function has been debugged and tested. It works.