Fix for possible null reference exception