Need to check error return code from this function in case it fails.