updated handleText method