instead of hardcondig '5' better if we set this condition as actions.length