upd. algorithm cat.