restructure request handling