simplified changes using preprocessor directives
Added try catch to enable execution via ODI when Standard Input is not available.