improve word parsing routine