working on merge algo