refactor database and ioc