finished AI implementation