UPD: improved performance