First working version with network rewrite