Refactor dynamic dimension setting