fix "Cannot read property value of undefined"