optimized context menu code