bugfixes for sequential algorithm