Merge code for random point generation