fixed comparison & counter problem