fix bugs with required and optional params