Added code to break loop when stop received