popup width fix and another refactor