moved rest logic to router