Refactored a function to use fewer parameters.