All cases now work, no recursive nightmare, code is easy to read and beautifully unoptimised