fixed bugs in atomic_flag