Fix bug in relation filtering