var names should be like remain_ptr and tok_len