updated with dynamic array