fail if necessary
moved closer to where needed and added clean up of .Last