refactored code so that querying images would only look at updated images.