fix issue with vals of length 1 being undefined