Refactoring + Improved Context Menu Logic