more robust null-checking