fixed handling of terminating condition at 10000