cleaned up, uses set algebra