Optimized command handler