ifelse and isvariable was unreliable when LSB was not found

(cherry picked from commit d888deda339e8d290879d6a98be3242861ebd305)