Refactored logic into its own service