fix .getText() weakness

The body of if block and else block look same to me.