FIX-some fixes of logic