Updated reverse scan logic