Refactored Code

The code has been refactored according to MVC architecture.