fixed working for some cases

now works for (ab)^+