refactored and added destructors