Changed if to switch and added on refresh, popup displays loading overlay