current version now completely working, but slow for large files