replace dao.close in the right place