changed variable in check on line 113 to be checking correct variable