Added check for a null bundle to avoid NPEs