improved set implementation