working on better algo