moving codes into library code