TDQ-9579:handle the empty context parameter case and improved the code.