replaced switchopen by logic