added conditional statements

added conditional statements for optional parameters