refactor to support environments and routes setting