Added errorhandling.