updated the router class to handle closure