factor out some common widget stuff