fix checking logic