adding more code to implement long polling