Refactoring and adding main
Implmenting main .. is it ready for test?