Refactor out common code, fix continious behaviour without polling use flag check condition