rewrite alignments count to be iterative instead of recurring