added null check before checking restult state