fixed flickering issue in  iOs, reworking auth code