Add better errorhandling