added error handling and default behaviour