Finish Server Part - Refactor code