streamlined parsing code; most likely has a  printing out of bounds bug