handle null cases better