clean up code, get request object from function