Added createStream()

also refactored code to use prototype pattern