improve performance of file_id function