updated invoice saving script