improved getInputStream function(). was broken before.