re-do ungolfed version with lessons learned from golfing