Modifying app query to remove duplicates