changed .nil? to .empty? in the unless statement. Seems to have fixed errors