file structure refactored,
errorhandling added