Added Server code for Stage 1 and Stage 2