Added random image loading. Seems that there are some cases that the algo does not work