improved coding of blog post Teehan+Lax