Use dicts rather than walls of elif

Neater!