refactoring wait for form to load