Fix data race by not removing shared access to input slice