reformatted to work in new plugin format