replace loop with slice copy