reversed this logic because otherwise `$image` can be an undefined variable.