better error handling via headers