Fully working
Code refactoring. Working