adding start of anchor handling.  not sure if algo is working completely correctly now