Added .extend as a dependency. Adjusted code to run on Node.js