Refactor how the text comparison is done