First working version
Refactoring