better algorithm for converting an infix expression