Added some AI code