had to add an offset counter as was returning an incorrect key length