The role of the inhomogeneous demagnetizing field on the reversal mechanism in nanowire arrays