move code to library