Minor refactoring in context menu directive