changed reading of structs, not sure if it works properly for structs containing varying types