Change find sets function slightly