Added handling for bad requests