added checkAttempt function