improved code style in lib/index.js