refactor, moving out from main-method