Fixed race condition with Firefox