add validator and fix some errors