avoid divide by None and zero