Implemented algorithm for 2nd strategy