Added check for valid image id before deleting'