DNN-5649 improve captcha logic