changed checking words is empty from sizeof(words) == 0 to checking if first element of words is null