[rewrite] better validation