fix conditions function