Fixed the infite loop the code was getting hung into, when an image added to the list was deleted from gallery