added function to check for existing image