add a bunch of code from dickgrune.com