implemented left factoring