final rev as presented on scala exchange 2013