added an extra test case and implemented it,
refactored main