Fixed with using code from Filemap.