finished functional.js