added error handling and selenium testing