Changes in script to detect unsuccesful attempts