implemented divide and distinct