rewrite network read write function