refactor init method