Moving request to a function