edit to tpl_search to return data and error message