Update dan

This seems to work, but I'm not sure about the actual accuracy of it in terms of matching correctly.  It does run through it all and return the offset