Restructed and refactored