Code from the book http://www.nostarch.com/erlang