tried to improve error reporting with limited success