Extract invite parsing to a function