fix close bug, but use std::set is not efficent