refactored & cleaned