Adapted for newer version of SP Client