code for generating trial sequences