Fixed r.js and created the function

Done.