clueanup

If you are going to do if/else on a lot of places,    currently 3 places.

then you pull that into a function.  makes what should be a very small util function,  less cohesive.