move code to lib/