refactor and add to lib adaptive controller