improve documentation, instantiate error object