Made server code more abstract