rearranged code to be a library, not a bundle