Hacky attempt to fix the possible race condition