in reply to Make code smaller and better

I see lots of repeated (or at least, remarkably similar) code in the if statements. I'm sure there's a way to "factor" that out into a function which you then call from the if's.

Arjen