added some checks in constructor