Switch to using invoke instead of subprocess