coded the patch phase