Fixing null pointer issue with async callback