Made getWords function to work