deserializing stream to type