refactoring n-tiers