changed to handle 'write_surf' function name also