Code from http://openinviter.com