updated merge_vars - added updateParams() function to clean and modularize code