added self termination support