Refactor code

This is how I would write this application.
Nothing special, just few things implemented in a different approach..