changed searchWords function