added null checks