Extract method for if check.