move part of the code to library