Refactor how functions use optional arguments