fix alternating closing issue