trying to avoid to call writePrimitive when not needed