ensure val before cancellation is correct - thanks @cyli