edited 'image' function