The nw3seq function seems to be working correctly now. I just need to get the scoring function, S_3 working as it should.