refined trimming and invite sending logic