changed rank logic to return phrase rather than zero