simplified check in stringToPrimitive
changed comment