tests pass. still very ugly.