rewrite replicate, fix read raw