divide js into foon.js and refactored