Imrpovements for index.js

Return when we can, safer and we can prevent some indent.
Merge pull request #14 from saveman71/improve-index.js

Improvements for index.js