delete function implemented, little cod refactoring