fix bugs / triangle trace revised