Completed compChooseWord function