Added error handling for invalid schemes