fixed stringToPrimitive optimization