added distinct constraint to query