4 line algorithm 1
algorithm 2