Working with little refactoring.
Refactored. Working example.