implements getWords function and passes specs for the funciton