better validation and hash counting