without some of the printf()s I threw in for debugging