refactoring into a distinct binary and library