code snippet cleanup - thanks to @jdalton