fix bug in branch loop
remove debug echo