fix 'undefined method [] for nil class'