working on select algo