Implementing new AI code