cleaning up code by adding session layer to server