implement reopen function