Removed uneeded print statements and added a try statement