Added error handling and simplifying fraction method.