PROPERLY separated algorithm into function

Passes in first address of sequence array as pointer.