Fix for index.js

Moving functions inside.