Updated script to include more error handling and allows checking remote systems