added delete function and some security