improve token parsing