restructuring code for new lib package