Added null-value error handling