separate logic in directive