revered last changes, added better error reporting