I have least problems with option 3, but drop the 'else if''s, that is not idomatic, just return and start a new 'if'. Also this function is only called once, so I still don't see the need for a separate function, call me a business-illogical-type :)