Updating code for null pointer