Changed to use ``lexical_cast`` and try-catch to numerical string check.