switching do dynamic allocation