finished up delete function and then added some checks