additional stuff for first replicate function added