add error handling
now with checks before disconnect and cancel