solves undefined issue, h/t Nigel