Refactored Code
Setting the timeout channel outside the loop