prevent race condition (fixes #134)