fix bug when there is only a single relation