Use 'head' & 'cur' instead of 'headptr'.