Added logic to control when AI crosses borders