added exception handling for input data