Refactored the impose length functionality in the dom module