pdated algorithm code
Resolved conflicts