fixed ugly undefined value bug in diff

added test to check for this

also:
cleaned a statement