Added functionality to handle more complex requests.