working version without branch policy