fix error undefined method text for Nil Class