avoid null pointer in function call