Updated to detect when it was ran either manually or automatically.