Refactoring to try and get rid of a pesky bug

I realize that my code now looks a lot more like the code in the
tutorial I followed, but I'm hunting a bug