If it's invalid to have settings null here. I'd just add at the top of the function `require(settings != null)`. Then you'll get an exception if that ever happens and you can remove the block.