Add function to convert object to array