improved error management and fix #76