added early terminatio and option to leave s constant