todo: replace $b[0] with lookup