autofit refactor