add visual debugging function, very poor performance