improved errorhandling