fixed major logic faults