Refactor router loading