Added type check for optional method arguments