fixed bug in applyAction