added deep paramter to toArray()