improving detection for cjs. fixes issue #9