BP implementation