autofocus refactored