Maybe the if (!settings) return; code could be done before the var foo = ... ?