start refactoring to a library