Adding a safety check for 'null' values.