initial code from dnnboards.codeplex.com