written the functionality for commandDelete.