Fixing an issue with optional params and "undefined" values