refactored some bits to properly work with dynamic