Fixing bug in find_prev logic