The transmission of financial shocks and leverage of financial institutions: An endogenous regime switching framework