Fixing a bug when wrong photo is loaded when rotating the last photo

thanks to github.com/dmac81