Refactored input loop
Changed return value name
Added exitcodes