error when you use non-array var as array. change this to something more elegant