fix for race conditions