added additional guard to prevent exceptions