solve a bug with imbricated switch statements