Refactored and cleaning