refactor of constructor