Added check to parse token function