refactored from to have a constructor