Retrieving @gtadam 's work from the mess of me not taking a branch. My bad