add id ordering and distinct