moving implementation into library when possible