sequential algorithm