improved error handling for insert-method