cleans up AI code