finished func for calc branch length