added delete function and fixed added function