Added array guards for dependency injection