changed the algorithm and so the script