changing asArray to toArray in process function