Add a condition such that,the polling stops when it crosses 5000.