now generalised for any number of samples or replicates