Moving functions from server to router