polling code improved