Added objectToArray function