reference:http://www.ruanyifeng.com/blog/2013/10/register.html