Popup position optimized
Refactoring