I don't think you need to check if connected/alive in cmd start...and you never need to do both as alive has a connected check built in so you'd only ever need to check alive. I'd remove the entire if statement.
You do not need to check if the task exists, just call remove_task().