merger random function