Fixed logic in merge helper