rework constructor function