optimize opening multiple files