Refactors method that decides if ai class is needed