first algorithm
modify first algorithm