Refactoring of set parameters.

Refactoring and this makes it more robust.