Fix after_request
- separate 2 functions