Eliminate `undefined method `[]' for nil:NilClass` bug