updated code for image comparing