added lots of server code to tex