bug fix, use last_index_pointer instead of last_pointer