Improved numeric comparison validity logic