Moved calculations to a separate .js file.