new constructor, some logic changes