optimize open and stoplose