implement funsets solution