rewrite the example code to include a working sample with comments to explain the correction. code should be in server side javascript and include required libraries