Refactored the addToParams function