fixed delete image logic