refactor: changes to make all tests work
refactor: small changes to cancellation functions
refactor: split up closure into two functions