refactoring forms and popups