added package deps
fixed JS array index bug