Fixing issue with key field returning null instead of 0