Fixed 101 by presuming all terms must be ints. Code runs, and quickly, but looks ugly