Refactored code, fixed namespace