correct bug with toPrimitiveArray