adding isValid function
constructors changed