Refactoring
Worked version