Update index.js 

Add fix for loading directories