make the server side code more modularized