improve error logging