Improved termination checking