fixing race condition

everything working - ready to merge back