Fix accidental string to array conversion and undefined variable error