modify router class to improve code structure