newer improved version: only 2 entities