fixed "undefined method `[] for nil:NilClass"