Refactoring captcha and counter