Bug fix when deleting image