Finished step 1.
Finished step 2.
Finished step 3.
Finishd step 4.
Finished step-5
Refactored code a bit.
Some refactoring.