moved all functionality back to lib