Handles both types of requests