I really think that could be optimized. That's a freaking mess of if/then statements!