added lots od Sleep 5s statements to prevent race conditions. Hacky but ATM seems to work