rather than generating this function for each request, lets cache it once and call it when needed.