Some changes in showPopupMenu function