A working decider (need to debug a bit)