Code refactor,

better error handling
more tests,
--int option added