added polymorphic read and write of lists