changed the errorhandling to exception throwing as this is better for performance (less tests)