Refactor to new class

Refactored the whole application into a new class for better readability. The same functionality is intact.