Optimal debt maturity and firm investment