The use of match() is risky to undefined method `[]' for nil:NilClass