updated to use the new apis and made into a package