Simplify some stuff

I was looking over this and I saw you duplicating some logic in where and case. Not very much, but if you end up wanting more, similar features you'll probably want to have it factored out.