Repalce NULL with 0 to prevent unexpectable error.