Defensive programming, avoid null cases, improve robustness