merge patches (credits: CastagnaIT)