added null handler trap guard