checkAndClick function added