refactored with design