This algorithm is done under a final semester project