use a query instead of maintaining ids in directory