Fix undefined index error

Fixes issue #1