I would prefer to have all this conversion logic moved into a separate class so it can be unit tested.