debug values and bugfix on legal formula