added more validation info and some optimization