to avoid merge probs
avoid merg probs
Final Algorithm