delay added to fix race condition issue