added autoclose feature