fixing a bug with the leftReduce functiong