putting back try except blocks removed for testing and delete unused code