Bad but clear job of getting rid of race conditions