refactor as a constructor