Improved the ai controller