fixing bug with storing image number