move streamEnd call to client side