edited parts of the nextImageButton function