Added null-safety check