adding switch definition thanks to @bigzaphod