make work for N samples