check for undefined instead of 0