You check val[0] == 0
If the check is passed it means that the info is not set on client.
Then you set it to val, but you have just check that val doesn't contain anything, you should make another variable to hold the default value you want to set in case the info is not already set.