error handling imporved, inputstream support begin