Refactor autononomous code