adding some error checking and a popup when you delete