- refactored logic into the library from the main method