resolved undefined method for NilClass error