replace switch to Factory Method