changed algorithm on state apply (have to be tested) leaved to older