Added error handling and changed naming