added null-checking