working version of replicator.  Ugly but working