modifying recurive version
refactored Set class