refactored1; part implemented