improved formatting
added some funtion definitions to sockets