merge merkle tree

- adding  PR for comments
use a generic error() here.