Update index.js

Several improvements:
events error, count, data