Update index.js

got rid of verbose null/undefined checks. Thanks Ant:)