Refactored to make routing more consistent