added average time and improved ai