Fixing object conversion to array issue