this might be a more efficient operation using python sets