updated sleep
updated to use Thread mode to avoid sleep