add invite sanity validation
try a bit of refactoring, still needs organization