fixed race condition- bad access thread issue