added error handling +more