Finished implementing parser, cheated a bit in  function