set count to 0 when undefined or null