implement read struct. TODO: FIXME