added auto exit feature