Expanded function to handle default arguments.