fix some bugs in BP functions