fixed misplaced check bug