Fixing race condition with phone app