use cell arrays for the different cases, rather than spaghetti code