All these ifs smell badly. Let's have two different classes for this instead, possibly using the Template Method or Strategy design pattern.