Prevent race conditions