Added small sleep in sync function to prevent 100% cpu usage
Removed unused variable