added complete server side code