refactored the code substantially to fix the regression from 'types' to 'type' in the results.  Added some comments and the code is a little shorter too
Merge pull request #37 from JacobGH111/master

PR for Jacob's variety