Task2 modified

Refactored the whole solution, many bugs fixed