implemented toLocalFile method and simplified some methods