added delete query and email function