Improved and working version of the AIEngine