Refactored per @parkr suggestions.  Much cleaner.