Fixed errorhandling