Replace for-loop with LayerStore's each-function in applyState