minor refactor of mainform