moved code to lib/