hw3 fixed check_pat