replace select with poll
improve encapsulation