Refactor captcha script.