added some stabilization code