fixed poll method and code refactoring