implementation of dynamic array