refactored the design