bug fix - logical error