improve ai and fix bugs