code generalisation to ensure that sample and study delegation is set up in the same way