refactored active optimization