refactor the check invitation filter