refactor setText method