fix replicateM bug