[wip] implement our own select loop