fixing bug, which allows to loose data for some conditions