added check for optional params