Add auto adapt code