some refactoring, use hash bytelength