use select() to make it truly event driven